import React from 'react';
import Reflux from 'reflux';
import {Control} from "react-keeper";
import * as ReactMixin from "react-mixin";
import {List} from "antd-mobile";
import Store from "./Store";
import Actions from "./Actions";
import YwhtpItem from "../../../../../components/ywhtp/YwhtpItem";

class YwhXj extends React.Component{
  constructor(props) {
    super(props);
  }

  componentWillMount() {
    Actions.getYwhTp(this.props.params.courtId);
  }

  render() {

    let rw = this.state.YwhXj.rw;
    let dyzRws, ldzRws, wyRws, zrRws;
    if (rw.CAST01.length > 0) {
      dyzRws = rw.CAST01.map(rw => <YwhtpItem courtName={this.state.YwhXj.court.name} rw={rw} />);
    } else {
      dyzRws = <div className="no-data-div">暂无投票</div>;
    }
    if (rw.CAST02.length > 0) {
      ldzRws = rw.CAST02.map(rw => <YwhtpItem courtName={this.state.YwhXj.court.name} rw={rw} />);
    } else {
      ldzRws = <div className="no-data-div">暂无投票</div>;
    }
    if (rw.CAST03.length > 0) {
      wyRws = rw.CAST03.map(rw => <YwhtpItem courtName={this.state.YwhXj.court.name} rw={rw} />);
    } else {
      wyRws = <div className="no-data-div">暂无投票</div>;
    }
    if (rw.CAST04.length > 0) {
      zrRws = rw.CAST04.map(rw => <YwhtpItem courtName={this.state.YwhXj.court.name} rw={rw} />);
    } else {
      zrRws = <div className="no-data-div">暂无投票</div>;
    }
    return (
      <div>
        <List renderHeader={() => "单元长投票"} className="my-list">{dyzRws}</List>
        <List renderHeader={() => "楼栋长投票"} className="my-list">{ldzRws}</List>
        <List renderHeader={() => "委员投票"} className="my-list">{wyRws}</List>
        <List renderHeader={() => "主任投票"} className="my-list">{zrRws}</List>
      </div>
    );
  }
}

ReactMixin.onClass(YwhXj, Reflux.connect(Store, 'YwhXj'));

export default YwhXj;
